import { Component, OnInit, Input } from '@angular/core';

import { AlertController } from '@ionic/angular';

import { AppGlobalService } from '../../shared/service/app-global.service';
import { EventService } from '../../shared/service/event.service';
import { HttpService } from '../../shared/service/http.service';
@Component({
  selector: 'app-exclusive-consultant',
  templateUrl: './exclusive-consultant.component.html',
  styleUrls: ['./exclusive-consultant.component.scss'],
})
export class ExclusiveConsultantComponent implements OnInit {
  @Input() tagData: any;
  appTypeCustom: any;
  constructor(
    private httpService: HttpService,
    private alertController: AlertController
  ) {
  }
  ngOnInit() {
    const bodyStyles = window.getComputedStyle(document.body);
    this.appTypeCustom = bodyStyles.getPropertyValue('--appTypeCustom').trim().replace('"', '').replace('"', '');
    if (this.tagData !== undefined) {
      if (this.tagData.data.imageUrl === "http://test") {
        this.tagData.data.imageUrl = "assets/img/headtrait.png";
      }
    } else {
      this.tagData = {
        type: "tag",
        style: "tag.AppSimpleDetailTagLogic",
        name: null,
        data: {
          area: "南山区/福田区",
          trade: "餐饮/大排档",
          phone: "13800012225",
          imageUrl: "assets/img/headtrait.png",
          name: "吴里啊",
          tag: "转让高级顾问"
        }
      };

    }
  }
  async call(mobile, name) {
    const alert = await this.alertController.create({
      header: this.tagData.data.nick_name,
      message: name + " " + mobile,
      buttons: [
        {
          text: '取消',
          role: 'cancel',
          cssClass: 'secondary'
        }, {
          text: '拨打',
          handler: () => {
            this.httpService.changeCallNumber(mobile);
          }
        }
      ]
    });
    await alert.present();
  }
}
